<template>
	<view class="space">
		<!-- #ifdef APP-PLUS -->
		<Hearder :name="'空间操作台'"></Hearder>
		<!-- #endif -->
		<view class="content">
			<view class="shurucon">
				<view class="currenttj">
					<view class="tjleft clearfix">
						<image :src="detail.avatarUrl"></image>
						<view>
							<view>{{detail.space_name}}的空间</view>
							<view>当日数据统计</view>
						</view>
					</view>
					<view class="thright" @click="show=true">
						{{currentime}}
						<image src="/static/images/sanj.png"></image>
					</view>
				</view>
				<view class="navbar clearfix">
					<view class="item">
						<view>交易金额</view>
						<view class="changecolor">{{detail.total_order_price}}</view>
					</view>
					<view class="item">
						<view>手续费总合</view>
						<view class="changecolor">{{detail.total_consignment_servicefee}}</view>
					</view>
					<view class="item">
						<view>交易订单</view>
						<view>{{detail.total_order_num}}</view>
					</view>
					<view class="item">
						<view>预约总数</view>
						<view>{{detail.appointment_num}}</view>
					</view>
				</view>
			</view>
			<view class="navbar sessions clearfix">
				<view class="item" @click="toPage(0,'numberlist?type=1')">
					<view>{{detail.purchase_morning_title}}预约</view>
					<view>{{detail.morning_appointment_num}}</view>
				</view>
				<view class="item"  @click="toPage(0,'numberlist?type=2')">
					<view>{{detail.purchase_afternoon_title}}预约</view>
					<view>{{detail.afternoon_appointment_num}}</view>
				</view>
				<view class="item"  @click="toPage(0,'numberlist?type=3')">
					<view>{{detail.purchase_night_title}}预约</view>
					<view>{{detail.night_appointment_num}}</view>
				</view>
			</view>
			<view class="list-con">
				<view class="every" v-for="(item,index) in navlist" :key="index" @click="toPage(index,item.route)">
					<view>
						<image :src="item.img"></image>
						<text>{{item.name}}</text>
					</view>
					<view>
						<text class="noright" v-if="index==7 && detail.split_price==0">未设置</text>
						<text class="noright" v-if="index==7 && detail.split_price>0">{{detail.split_price}}</text>
						<u-icon name="arrow-right" color="#999" size="16"></u-icon>
					</view>
				</view>
			</view>
		</view>
		<u-popup mode="center" :round="5" :show="showflag">
			<view class="numbergoods_con">
				<view class="goods-title">空间主转移</view>
				<view class="identifier" style="margin-top: 0;">
					<input placeholder="请输入对方空间编号" placeholder-style="color:#999" v-model="space_no"/>
				</view>
				<view class="sml-btn clearfix">
					<view @click="showflag = false">取消</view>
					<view @click="zhuanysure">确认</view>
				</view>
			</view>
		</u-popup>
		<u-datetime-picker
			:show="show"
			v-model="value1"
			mode="date"
			:minDate="31507200000"
			@confirm="confirm"
			@cancel="cancel"
		></u-datetime-picker>
		<u-modal
		:show="transferflag" 
		title="是否确认转移,
		一但转移无法恢复" 
		width="300"
		border-radius="0"
		:show-cancel-button="true"
		cancel-color="#323232"
		confirm-color="#323232"
		:title-style="{'font-size':'32rpx','font-weight': '800'}"
		:content-style="{color:'#999','font-size':'28rpx'}"
		:cancel-style="{'border-right': '2rpx solid $uni-background-color'}"
		@confirm="confirmt"
		@cancel="cancel">
		</u-modal>
		<Paypwd ref="paystatus" :totalprice="totalprice" @paymoney="paymoney"></Paypwd>
	</view>
</template>

<script>
	import Paypwd from '@/pages/common/paypwd.vue'
	export default {
		data(){
			return{
				navlist:[
					{img:'/static/images/k1.png',name:'专区时间管理',route:'prefecture'},
					{img:'/static/images/k2.png',name:'空间会员管理',route:'viplist'},
					{img:'/static/images/k3.png',name:'空间订单管理',route:'spacemanage'},
					{img:'/static/images/k4.png',name:'空间订单转移',route:'transfer'},
					{img:'/static/images/k5.png',name:'设置空间编号',route:'spacenumber'},
					{img:'/static/images/k6.png',name:'会员预约开关',route:'memberyy'},
					{img:'/static/images/k7.png',name:'空间主转移',route:''},
					{img:'/static/images/k8.png',name:'自动拆分设置',route:'autosplit'}
				],
				detail:{},
				showflag:false,
				space_no:'',
				show:false,
				value1: Number(new Date()),
				currentime: '',
				statuslist:[],
				transferflag:false,
				totalprice:0
			}
		},
		onShow() {
			this.request('/space/getSpaceConsole').then(res => {
				if(res.data.code==1){
					this.detail = res.data.data
					this.currentime = res.data.data.order_time
					this.navlist.map((value,index)=>{
						value.route = value.route.split("?")[0]
						value.route = value.route + '?space_id='+this.detail.space_id
					})
				}
			})
		},
		methods:{
			zhuanysure(){
				this.showflag = false
				this.transferflag = true
			},
			confirm(e){
				this.currentime = uni.$u.timeFormat(e.value, 'yyyy-mm-dd')
				this.show = false
				this.request('/space/getSpaceConsole',{order_time:this.currentime}).then(res => {
					if(res.data.code==1){
						this.detail = res.data.data
						this.navlist.map((value,index)=>{
							value.route = value.route + '?space_id='+this.detail.space_id
						})
					}
				})
			},
			cancel(){
				this.show = false
				this.transferflag = false
			},
			confirmt(){
				this.request('/member/getIsPayPassword').then(res => {
					if(res.data.code==1){
						this.transferflag = false
						if(res.data.data==0){
							this.$refs.paystatus.payflag = true
						}else{
							this.$refs.paystatus.zhifuflag = true
						}
					}else{
						this.$tip(res.data.msg)
					}
				})
			},
			paymoney(){
				this.request('/space/toSpaceTransfer',{space_no:this.space_no}).then(res => {
					if(res.data.code==1){
						this.$tip(res.data.msg)
						this.$refs.paystatus.zhifuflag = false
						setTimeout(()=>{
							uni.navigateBack()
						},500)
					}else{
						this.$tip(res.data.msg)
					}
				})
			},
			toPage(index,route){
				if(index==6){
					this.showflag = true
				}else{
					uni.navigateTo({
					    url: route
					});
				}
			}
		},
		components:{
			Paypwd
		}
	}
</script>

<style scoped lang="scss">
	.space{
		min-height: 100%;
		background: $uni-background-color;
		.content{
			.shurucon{
				height: 266rpx;
				background: $uni-item-color;
				.currenttj{
					display: flex;
					justify-content: space-between;
					align-items: center;
					margin: 0 4%;
					padding-top: 46rpx;
					.tjleft{
						image{
							float: left;
							width: 100rpx;
							height: 100rpx;
							border-radius: 50%;
						}
						>view{
							float: left;
							margin-left: 20rpx;
							view{
								font-size: 24rpx;
								color: #fff;
								&:first-of-type{
									font-size: 32rpx;
									font-weight: 800;
									margin-bottom: 16rpx;
									
								}
							}
						}
					}
					.thright{
						width: 223rpx;
						height: 58rpx;
						border: 1rpx solid #fff;
						border-radius: 58rpx;
						color: #fff;
						text-align: center;
						line-height: 58rpx;
						font-size: 24rpx;
						image{
							width: 16rpx;
							height: 8rpx;
							margin-left: 8rpx;
						}
					}
				}
			}
			.navbar{
				background: #fff;
				border-radius: 10rpx;
				padding: 30rpx 0;
				margin: 36rpx 4% 0;
				.item{
					position: relative;
					float: left;
					width: 25%;
					text-align: center;
					view{
						text-align: center;
						color: #333;
						&:first-of-type{
							font-size: 24rpx;
							margin-bottom: 16rpx;
						}
					}
					.changecolor{
						color: #F83706;
					}
				}
			}
			.sessions{
				margin-top: 94rpx;
				.item{
					width: 33.3%;
				}
			}
			.list-con{
				background: #fff;
				margin: 30rpx 4%;
				border-radius: 20rpx;
				.every{
					display: flex;
					justify-content: space-between;
					align-items: center;
					border-bottom: $uni-border-bottom;
					height: 110rpx;
					padding: 0 30rpx 0 36rpx;
					&:first-of-type{
						text{
							top: 2rpx;
						}
					}
					image{
						width: 34rpx;
						height: 34rpx;
					}
					text{
						position: relative;
						top: 4rpx;
						margin-left: 20rpx;
					}
					.u-icon{
						top: 4rpx;
						margin-left: 30rpx;
					}
					.noright{
						color: $uni-item-color;
					}
				}
			}
		}
		.numbergoods_con{
			width: 580rpx;
			.goods-title{
				font-size: 32rpx;
				color: #202020;
				font-weight: 800;
				text-align: center;
				padding: 38rpx 0;
			}
			.identifier{
				width: 478rpx;
				height: 88rpx;
				border: 1rpx solid #999;
				margin: 28rpx auto 50rpx;
				input{
					font-size: 26rpx;
					height: 100%;
					text-align: center;
				}
			}
			.sml-btn{
				height: 92rpx;
				border-top: $uni-border-bottom;
				view{
					float: left;
					width: 50%;
					text-align: center;
					font-size: 28rpx;
					box-sizing: border-box;
					line-height: 92rpx;
					&:first-of-type{
						color: #999;
						border-right: $uni-border-bottom;
					}
				}
			}
		}
		/deep/.u-modal__title{
			span{
				line-height: 50rpx;
				color: #323232;
			}
		}
		/deep/.u-modal__content{
			padding-top: 0 !important;
		}
	}
</style>